<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=utf-8" />
    <title>
      6.46.&nbsp;Kmod-23
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </head>
  <body class="lfs" id="lfs-8.0">
    <div class="navheader">
      <h4>
        Linux From Scratch - Version 8.0
      </h4>
      <h3>
        第六章 安装基本系统软件
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="xz.html" title="Xz-5.2.3">上一页</a>
          <p>
            Xz-5.2.3
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="gettext.html" title=
          "Gettext-0.19.8.1">下一页</a>
          <p>
            Gettext-0.19.8.1
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter06.html" title=
          "第六章 安装基本系统软件">返回</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 8.0 ">首页</a>
        </li>
      </ul>
    </div>
    <div class="wrap" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="ch-system-kmod" name="ch-system-kmod"></a>6.46. Kmod-23
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <p>
          Kmod 软件包包含了用于加载内核模块的库和工具。
        </p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">预计构建时间:</strong>
              <span class="segbody">0.1 SBU</span>
            </div>
            <div class="seg">
              <strong class="segtitle">需要磁盘空间:</strong>
              <span class="segbody">10.3 MB</span>
            </div>
          </div>
        </div>
      </div>
      <div class="installation" lang="en" xml:lang="en">
        <h2 class="sect2">
          6.46.1. Kmod 安装过程
        </h2>
        <p>
          准备编译 Kmod:
        </p>
        <pre class="userinput">
<kbd class="command">./configure --prefix=/usr          \
            --bindir=/bin          \
            --sysconfdir=/etc      \
            --with-rootlibdir=/lib \
            --with-xz              \
            --with-zlib</kbd>
</pre>
        <div class="variablelist">
          <p class="title">
            <strong>配置选项的意义:</strong>
          </p>
          <dl class="variablelist">
            <dt>
              <span class="term"><em class="parameter"><code>--with-xz,
              --with-zlib</code></em></span>
            </dt>
            <dd>
              <p>
                这些选项将使能 Kmod 处理压缩的内核模块的能力。
              </p>
            </dd>
            <dt>
              <span class="term"><em class=
              "parameter"><code>--with-rootlibdir=/lib</code></em></span>
            </dt>
            <dd>
              <p>
                这些选项将保证不同的库相关文件放在正确的目录。
              </p>
            </dd>
          </dl>
        </div>
        <p>
          编译软件包:
        </p>
        <pre class="userinput">
<kbd class="command">make</kbd>
</pre>
        <p>
          这个软件包并没有包含可以在 LFS chroot 环境中可以运行的测试套件。
          至少需要 git 程序，而且有些测试在 git 版本库之外无法运行。
        <p>
          安装软件包, 然后创建兼容 Module-Init-Tools (之前用于处理 Linux 内核模块的软件包)工具的链接:
        </p>
        <pre class="userinput">
<kbd class="command">make install

for target in depmod insmod lsmod modinfo modprobe rmmod; do
  ln -sfv ../bin/kmod /sbin/$target
done

ln -sfv kmod /bin/lsmod</kbd>
</pre>
      </div>
      <div class="content" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="contents-kmod" name="contents-kmod"></a>6.46.2. Kmod 的内容
        </h2>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">安装的程序:</strong>
              <span class="segbody">depmod (link to kmod), insmod (link to
              kmod), kmod, lsmod (link to kmod), modinfo (link to kmod),
              modprobe (link to kmod), and rmmod (link to kmod)</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed library:</strong>
              <span class="segbody">libkmod.so</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3>
            简要介绍
          </h3>
          <table border="0" class="variablelist">
            <colgroup>
              <col align="left" valign="top" />
              <col />
            </colgroup>
            <tbody>
              <tr>
                <td>
                  <p>
                    <a id="depmod" name="depmod"></a><span class=
                    "term"><span class=
                    "command"><strong>depmod</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    基于它在已存在的模块集中发现的符号创建一个依赖文件;
                    <span class="command"><strong>modprobe</strong></span> 将使用这个依赖文件来自动加载需要的模块
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="insmod" name="insmod"></a><span class=
                    "term"><span class=
                    "command"><strong>insmod</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    在正在运行的内核中安装一个可以加载的模块
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="kmod" name="kmod"></a><span class=
                    "term"><span class=
                    "command"><strong>kmod</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    加载和卸载内核模块
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="lsmod" name="lsmod"></a><span class=
                    "term"><span class=
                    "command"><strong>lsmod</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    列出当前已加载的模块
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="modinfo" name="modinfo"></a><span class=
                    "term"><span class=
                    "command"><strong>modinfo</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    检查一个与内核模块相关联的目标文件然后显示所有它能收集的信息
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="modprobe" name="modprobe"></a><span class=
                    "term"><span class=
                    "command"><strong>modprobe</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    使用 <span class=
                    "command"><strong>depmod</strong></span> 命令生成的依赖文件来自动加载相关的模块
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="rmmod" name="rmmod"></a><span class=
                    "term"><span class=
                    "command"><strong>rmmod</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    在运行的内核中卸载模块
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="libkmod" name="libkmod"></a><span class=
                    "term"><code class="filename">libkmod</code></span>
                  </p>
                </td>
                <td>
                  <p>
                    这个库用于让别的程序来加载和卸载内核模块
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="xz.html" title="Xz-5.2.3">上一页</a>
          <p>
            Xz-5.2.3
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="gettext.html" title=
          "Gettext-0.19.8.1">下一页</a>
          <p>
            Gettext-0.19.8.1
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter06.html" title=
          "第六章 安装基本系统软件">返回</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 8.0 ">首页</a>
        </li>
      </ul>
    </div>
  </body>
</html>
